#include "Anim_Pack.h"

Anim_Pack::Anim_Pack(std::string nom, std::string statut_initial):Anim_Holder(nom,statut_initial)
{

}

Anim_Pack::~Anim_Pack()
{
    //dtor
}

void Anim_Pack::AddAnim(std::string tnom,std::string nom,int nbr,MainLoader *mdat,std::vector<int> V, bool reset,bool idle){
    Anim A (tnom,nom,nbr,mdat,V,reset,idle);
    v_anim.push_back(A);
}

int Anim_Pack::GetCurAnim(){
    int n=v_anim.size();

    int i;
    for (i=0;i<n;i++){
        if((v_anim[i].GetTName())==Statut){
            cur_anim=i;
            return i;
            }
        }
    std::cout<<std::endl<<"Erreur, statut : "<<Statut<<" n'existe pas";
    return -1;
}

sf::Sprite Anim_Pack::GetSprite(){

    this->GetCurAnim();
    int i= cur_anim;

    if (v_anim[i].Ret_Idle()){

        Statut=v_anim[0].GetName();
        this->GetCurAnim();
        i= cur_anim;
    }
    v_anim[i].reset();


    return v_anim[i].GetSprite();

}


